//
//  SexViewController.m
//  UITestDemo
//
//  Created by Qianfeng on 15/8/14.
//  Copyright (c) 2015年 Qianfeng. All rights reserved.
//

#import "SexViewController.h"

@interface SexViewController ()

@end

@implementation SexViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUI];
}
-(void)initUI
{
    NSArray *titles = @[@"这是第0项",@"这是第1项",@"这是第2项"];
    for (int i = 0 ; i <3; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(20, 70+i*50, self.view.frame.size.width-40, 40);
        [button setTitle:titles[i] forState:UIControlStateNormal];
        button.titleLabel.textColor = [UIColor whiteColor];
        button.backgroundColor = [UIColor lightGrayColor];
        [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
    }
}
-(void)btnClick:(UIButton*)button
{
    self.handler(button.titleLabel.text);
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
